package com.sui.bigdata.rtcadmin.dto;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.sui.bigdata.rtcadmin.repository.model.Meta;
import com.sui.bigdata.rtcadmin.util.DateUtils;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.Date;

/**
 * @author YongChen
 * @date 2019/11/6 14:41
 * @description
 * @email yong_chen@sui.com
 */
@Data
@Accessors(chain = true)
public class MetaDto {

    @JSONField(name = "table_name")
    private String tableName;
    @JSONField(name = "type")
    private String type;
    @JSONField(name = "field_info")
    private String fieldInfo;
    @JSONField(name = "prop")
    private String prop;
    @JSONField(name = "create_time")
    private String createTime;
    @JSONField(name = "update_time")
    private String updateTime;

    public static MetaDto buildMetaDto(Meta meta){
        if (meta == null){
            return null;
        }
        return new MetaDto()
                .setTableName(meta.getTableName())
                .setType(meta.getType())
                .setFieldInfo(meta.getFieldInfo())
                .setProp(meta.getProp())
                .setCreateTime(DateUtils.formatDate(meta.getCreateTime(),DateUtils.YYYY_MM_DD_HH_MM_SS))
                .setUpdateTime(DateUtils.formatDate(meta.getUpdateTime(),DateUtils.YYYY_MM_DD_HH_MM_SS));
    }

}
